<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm'); ?>

<?php include _include(HAYA_FILE_HTML.'common/tab.htm'); ?>

<div class="container">
	<div class="row">
		
		<div class="col-md-12 m-b-sm">

			<div class="card">
				<div class="card-block">

					<h4 class="card-title">
						附件信息
					</h4>
			
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							ID：
						</label>
						<div class="col-sm-10">
							<?php echo $attach['aid']; ?>
						</div>
					</div>
			
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							文件名：
						</label>
						<div class="col-sm-10">
							<?php echo $attach['orgfilename']; ?>
						</div>
					</div>
			
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							类型：
						</label>
						<div class="col-sm-10">
							<i class="icon filetype <?php echo $attach['filetype']; ?>"></i>
							<?php echo $attach['filetype']; ?>
						</div>
					</div>
			
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							大小：
						</label>
						<div class="col-sm-10">
							<?php echo humansize($attach['filesize']); ?>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							创建时间：
						</label>
						<div class="col-sm-10">
							<?php echo date('Y-m-d H:i:s', $attach['create_date']); ?>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							所属帖子：
						</label>
						<div class="col-sm-10">
							<a href="../<?php echo url("thread-$thread[tid]");?>" target="_blank">
								<?php if($thread['closed'] > 0) { ?><i class="icon-lock" aria-hidden="true"></i><?php } ?>
								[<?php echo $thread['create_date_fmt'];?>]
								<?php echo strip_tags($thread['subject']);?>
								-<?php echo $thread['user']['username'];?>
							</a>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							所属用户：
						</label>
						<div class="col-sm-10">
							<a href="../<?php echo url("user-$attach[uid]");?>" target="_blank">
								<?php echo $user['username'];?>
							</a>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							所属回帖：
						</label>
						<div class="col-sm-10">
							<a href="javascript:;">
								[<?php echo $post['create_date_fmt'];?>]
								<?php echo strip_tags($post['message_fmt']);?>
								-<?php echo $post['user']['username'];?>
							</a>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							下载次数：
						</label>
						<div class="col-sm-10">
							<?php echo intval($attach['downloads']); ?>
						</div>
					</div>
					
					<?php if (!empty($attach['width'])) { ?>
				
						<div class="form-group row m-b-sm">
							<label class="col-sm-2 form-control-label text-right">
								图片规格：
							</label>
							<div class="col-sm-10">
								<?php echo $attach['width']; ?>
								X 
								<?php echo $attach['height']; ?>
							</div>
						</div>
					
					<?php } ?>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							备注：
						</label>
						<div class="col-sm-10">
							<?php if (!empty($attach['comment'])) { ?>
								<?php echo $attach['comment']; ?>
							<?php } else { ?>
								~
							<?php } ?>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							下载：
						</label>
						<div class="col-sm-10">
							<a href="../<?php echo url('attach-download-'.$attach['aid']); ?>">
								点击下载
							</a>
						</div>
					</div>
				
					<div class="form-group row m-b-sm">
						<label class="col-sm-2 form-control-label text-right">
							预览：
						</label>
						<div class="col-sm-10">
							<?php echo $attach['url']; ?>
							<?php 
								if (!empty($attach['width']) 
									&& isset($config['is_avatar'])
									&& ($config['is_avatar']['value'] == 1)
								) { 
							?>
								<div class="row m-t-sm">
									<div class="col-sm-12">
										<img src="../<?php echo $attach['url']; ?>" style="width:100%;" />
									</div>
								</div>
							<?php } ?>
						</div>
					</div>
					
					<div class="form-group row">
						<label class="col-sm-2 form-control-label"></label>
						<div class="col-sm-10">
							<a href="javascript:;" data-id="<?php echo $attach['aid']; ?>" class="btn btn-primary btn-block" id="js-file-delete">删除</a>
							<a role="button" class="btn btn-secondary btn-block m-t-1" href="javascript:history.back();"><?php echo lang('back');?></a>
						</div>
					</div>
				
				</div>
			</div>
		
		</div>
		
	</div>
</div>

<?php include _include(HAYA_FILE_HTML.'common/footer.htm'); ?>

<script>
var jdelete = $("#js-file-delete");
jdelete.on('click', function(){
	if (!window.confirm("确认要删除文件吗？")) {
		return false;
	}

	var aid = $(this).attr('data-id');
	$.xpost(xn.url('attach-delete'), {aid:aid}, function(code, message) {
		if (code != 0) {
			return $.alert(message);
		} else {
			$.alert(message);
			
			window.location.href = xn.url('attach-attachs');
		}
	});

});
</script>
